package com.generator.service.common;

/**
 * MySQL字段类型对应的JAVA类型
 * User: wangyanginfo
 * Date: 13-4-2
 * Time: 下午1:02
 */
public enum MySqlFieldType {

    VARCHAR("VARCHAR", "java.lang.String", "L+N", 12),
    CHAR("CHAR", "java.lang.String", "N", 1),
    BLOB("BLOB", "java.lang.byte[]", "L+N", -4),
    TEXT("TEXT", "java.lang.String", "65535", -1),
    INTEGER("INTEGER", "java.lang.Long", "4", 4),
    TINYINT("TINYINT", "java.lang.Integer", "3", -6),
    SMALLINT("SMALLINT", "java.lang.Integer", "5", 5),
    MEDIUMINT("MEDIUMINT", "java.lang.Integer", "8", 4),
    BIT("BIT", "java.lang.Boolean", "1", -7),
    BIGINT("BIGINT", "java.math.BigInteger", "20", -5),
    FLOAT("FLOAT", "java.lang.Float", "12", 7),
    DOUBLE("DOUBLE", "java.lang.Double", "22", 8),
    DECIMAL("DECIMAL", "java.math.BigDecimal", "11", 3),
    BOOLEAN("BOOLEAN", "java.lang.Integer", "1", -6),
    ID("BIGINT", "java.lang.Long", "11", 4),
    DATE("DATE", "java.sql.Date", "10", 91),
    TIME("TIME", "java.sql.Time", "8", 92),
    DATETIME("DATETIME", "java.sql.Timestamp", "19", 93),
    TIMESTAMP("TIMESTAMP", "java.sql.Timestamp", "19", 93),
    YEAR("YEAR", "java.sql.Date", "4", 91);

    // MySql数据库类型
    private String jdbcType;
    // JAVA类型
    private String javaType;
    // 长度
    private String length;
    // 索引
    private int index;

    MySqlFieldType(String jdbcType, String javaType, String length, int index) {
        this.jdbcType = jdbcType;
        this.javaType = javaType;
        this.length = length;
        this.index = index;
    }

    public String getJdbcType() {
        return jdbcType;
    }

    public void setJdbcType(String jdbcType) {
        this.jdbcType = jdbcType;
    }

    public String getJavaType() {
        return javaType;
    }

    public void setJavaType(String javaType) {
        this.javaType = javaType;
    }

    public String getLength() {
        return length;
    }

    public void setLength(String length) {
        this.length = length;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
